#ifndef _GRAPHICS_MANAGER_H
#define _GRAPHICS_MANAGER_H

#include <d3dx9.h>
#include "Utils\Types.h"
#include "Math\Color.h"
#include "Math\Vector3.h"
#include "Math\Matrix44.h"

#include "Camera.h"
#include "Frustum.h"

class CGraphicsManager
{
public:
	CGraphicsManager(void);
	~CGraphicsManager(void);

	bool Init(HWND hWnd, bool fullscreenMode, uint32 widthScreen, uint32 heightScreen);
	void DeInit();
	void Update();

	void Release();

	void BeginRendering();
	void EndRendering();
	void SetupMatrices(CCamera *inCamera);

	void DrawLine (const Vect3f &PosA, const Vect3f &PosB, CColor color=colWHITE);
	void DrawAxis	 (float Size);
	void DrawCube	 (float Size, CColor color=colWHITE);
	void DrawBox (float SizeX, float SizeY, float SizeZ, CColor color=colWHITE);
	void DrawGrid (float Size, CColor color=colWHITE, int GridX=10, int GridZ=10);
	void DrawPlane(float Size, const Vect3f& normal, float distance, CColor Color=colWHITE, int GridX=10, int GridZ=10);

	void GetWindowRect( HWND hwnd );

	HWND  m_hWnd;	// 3D render window handle
	LPDIRECT3D9 m_pD3D;	 // direct3d interface
	LPDIRECT3DDEVICE9  m_pD3DDevice; // direct3d device
	uint32 m_uWidth;	// width of the client windows
	uint32 m_uHeight; // height of the client windows
	//CColor m_BackbufferColor_debug;		// Clear the backbuffer with this color in debug mode 
	//CColor m_BackbufferColor_release;	// Clear the backbuffer with this color in release mode
	LPDIRECT3DSURFACE9 m_pBackBuffer;
	bool     m_bIsOk;  // Initialization boolean control

	CColor m_BackbufferColor_debug;        // Clear the backbuffer with this color in debug mode 
	CColor m_BackbufferColor_release;      // Clear the backbuffer with this color in

	bool m_bPaintSolid;

	float m_yaw;
	float m_pitch;
	float m_speed;
	Vect3f m_pos;

	CFrustum			m_Frustum;

	void SetTransform(D3DXMATRIX& matrix);
	void SetTransform(Mat44f& matrix);
};

#endif